//
//  UITextField+Category.m
//  Project_Demo
//
//  Created by caoxiaozhu on 2018/7/5.
//  Copyright © 2018年 caoxiaozhu. All rights reserved.
//

#import "UITextField+Category.h"

@implementation UITextField (Category)

+(UITextField *)textFieldWithPlaceHolder:(NSString *)placehoder PlaceHolderColor:(UIColor *)placeColor BorderType:(UITextBorderStyle)borderStyle SecureTextEntry:(BOOL)securety Text:(NSString *)text TextColor:(UIColor *)textColor BackgroundColor:(UIColor *)bacColor KeyboardType:(UIKeyboardType)keyboardType{
    
    UITextField *textField = [[UITextField alloc]init];
    textField.borderStyle = borderStyle;
    textField.secureTextEntry = securety;
    textField.keyboardType = keyboardType;
    
    if (placehoder) {
        textField.placeholder = placehoder;
    }
    
    if (text) {
        textField.text = text;
    }
    
    if (textColor) {
        textField.textColor = textColor;
    }
    
    if (placeColor) {
        textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placehoder attributes:@{NSForegroundColorAttributeName: placeColor}];
    }else{
        if (placehoder) {
            textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placehoder attributes:@{NSForegroundColorAttributeName: [UIColor hex:@"d9d9dd"]}];
        }
    }
    
    
    if (bacColor) {
        textField.backgroundColor = bacColor;
    }
    
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    return textField;
}

@end
